package com.zimin.cloud.web.controller.wiki;

import com.zimin.cloud.mine.pojo.wiki.business.CategoryBO;
import com.zimin.cloud.mine.pojo.wiki.business.EbookBO;
import com.zimin.cloud.wiki.api.ICategoryFeign;
import com.zimin.cloud.wiki.api.IEbookFeign;
import com.zimin.shared.annotation.RedisLock;
import com.zimin.shared.pojo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Mono;

/**
 * @author zimin
 * @since 2021/11/2 4:52 下午
 */
@RestController
@RequestMapping("/web/wiki/category")
@Slf4j
public class WebWikiCategoryController {

    @Autowired
    private ICategoryFeign categoryFeign;

    @GetMapping
    public Mono<Result> categoryList(CategoryBO categoryBO) {
        Result result = categoryFeign.categoryList(categoryBO);
        return Mono.just(result);
    }


    @GetMapping("/all")
    public Mono<Result> all(CategoryBO categoryBO) {
        Result result = categoryFeign.categoryAll(categoryBO);
        return Mono.just(result);
    }


    @PostMapping
    @RedisLock
    public Mono<Result> saveCategory(@RequestBody CategoryBO categoryBO) {
        Result result = categoryFeign.saveCategory(categoryBO);
        return Mono.just(result);
    }

    @PutMapping
    @RedisLock
    public Mono<Result> updateCategory(@RequestBody CategoryBO categoryBO) {
        Result result = categoryFeign.updateCategory(categoryBO);
        return Mono.just(result);
    }

    @DeleteMapping("/{id}")
    public Mono<Result> removeById(@PathVariable(name = "id") String id) {
        Result result = categoryFeign.removeCategoryById(id);
        return Mono.just(result);
    }


}
